+function(a){"use strict";function b(b){var c,e=arguments;return this.each(function(){var f=a(this),g=f.data("treeFy");if(!g){var h=a.extend(!0,{},a.fn.treeFy.defaults,"object"==typeof b&&b);f.data("treeFy",g=new d(this,h))}if("string"==typeof b)if(1==e.length){var i=g[b].call(g);"undefined"!=typeof i&&(c=i)}else{var i=g[b].apply(g,Array.prototype.slice.call(e,1));"undefined"!=typeof i&&(c=i)}}),"undefined"!=typeof c?c:this}var c=function(a){var b=/treetable-/,c=/treetable-parent-/;this.row=a,this.id=null,b.test(this.row.attr("data-node"))&&(this.id=this.row.attr("data-node").substring(this.row.attr("data-node").lastIndexOf("-")+1)),this.parentId=null,c.test(this.row.attr("data-pnode"))&&(this.parentId=this.row.attr("data-pnode").substring(this.row.attr("data-pnode").lastIndexOf("-")+1)),this.children=[],this.status=!0};c.prototype.addChildren=function(b){var d=this,e="treetable-parent-"+d.id,f=b.find('[data-pnode="'+e+'"]');0!=f.length&&a.each(f,function(e,f){var g=new c(a(f));d.children.splice(0,0,g),g.addChildren(b)})},c.prototype.initIndent=function(b){this.row.find(".treetable-indent").remove();for(var c=this.row.find(".treetable-expander"),d=this.getDepth(b.options),e=0;d>e;e++){var f=b.options.indentTemplate;a(f).insertBefore(c)}},c.prototype.initExpander=function(b){var c=this,d=c.row.find("td").get(b.options.treeColumn),e=c.row.find(".treetable-expander");e&&e.remove();var f=b.options.expanderTemplate;a(f).prependTo(d).click(function(){c.toggle()})},c.prototype.renderExpand=function(a){var b=this.row.find(".treetable-expander");b?this.row.hasClass("treetable-collapsed")?(b.removeClass(a.options.expanderExpandedClass),b.addClass(a.options.expanderCollapsedClass)):(b.removeClass(a.options.expanderCollapsedClass),b.addClass(a.options.expanderExpandedClass)):(this.initExpander(a),this.renderExpand(a))},c.prototype.toggle=function(){this.row.hasClass("treetable-expanded")?this.isLeaf()||this.row.hasClass("treetable-collapsed")||(this.row.removeClass("treetable-expanded"),this.row.addClass("treetable-collapsed")):this.isLeaf()||this.row.hasClass("treetable-expanded")||(this.row.removeClass("treetable-collapsed"),this.row.addClass("treetable-expanded"))},c.prototype.isLeaf=function(){return 0===this.children.length},c.prototype.isCollapsed=function(a){var b=0===this.getDepth(a);if(b)return!1;var c=this.getParentNode(a);return c.row.hasClass("treetable-collapsed")?!0:c.isCollapsed(a)},c.prototype.getDepth=function(a){var b=this.getParentNode(a);return null===b?0:b.getDepth(a)+1},c.prototype.getParentNode=function(a){return null===this.parentId?null:""==this.parentId?a.allNodesObject.undefined:a.allNodesObject[this.parentId]},c.prototype.getNodeById=function(a,b){var d="treetable-"+a,e=b.find('[data-node="'+d+'"]'),f=new c(e);return f.addChildren(b),f};var d=function(b,c){this.options=c,this.$table=a(b);var d=this.getAllNodes();this.initTree(d)};d.VERSION="1.3.0",d.prototype.getAllNodes=function(){var b=this,d=[];a.each(b.$table.find("tr"),function(e,f){var g=a(f).attr("data-node"),h=/treetable-/;if(h.test(g)){var i=new c(a(f));i.addChildren(b.$table),d.push(i);var j=g.replace(h,"");b.options.allNodesObject[j]=i}});var e=b.$table.find('[data-node="treetable-"]'),f=new c(e);return f.addChildren(b.$table),b.options.allNodesObject.undefined=f,d},d.prototype.initTree=function(b){var c=this,d=[];a.each(b,function(){var a=0===this.children.length;a||this.row.addClass(c.options.initStatusClass),this.parentId||d.push(this)}),c.initNode(d),c.render(d)},d.prototype.initNode=function(b){var c=this;a.each(b,function(){var b=this.row;a.each(this.children,function(){b.after(this.row)}),c.initNode(this.children),this.initExpander(c),this.initIndent(c);var d=this.row,e=[];e.push(this),d.find(".treetable-expander").on("click",function(a){a.stopPropagation(),c.render(e)})})},d.prototype.render=function(b){var c=this;a.each(b,function(){this.isCollapsed(c.options)?this.row.hide():this.row.show(),this.isLeaf()||(this.renderExpand(c),c.render(this.children))})},d.prototype.addIndent=function(b,c){c.find(".treetable-indent").remove();for(var d=c.find(".treetable-expander"),e=0;b>e;e++){var f='<span class="treetable-indent"></span>';a(f).insertBefore(d)}};var e=a.fn.treeFy;a.fn.treeFy=b,a.fn.treeFy.Constructor=d,a.fn.treeFy.defaults={expanderTemplate:'<span class="treetable-expander"></span>',indentTemplate:'<span class="treetable-indent"></span>',expanderExpandedClass:"fa fa-angle-down",expanderCollapsedClass:"fa fa-angle-right",treeColumn:0,initStatusClass:"treetable-expanded",allNodesObject:{}},a.fn.treeFy.noConflict=function(){return a.fn.treeFy=e,this}}(jQuery);